package edu.xaut.bookingsys.controller;

import cn.dev33.satoken.util.SaResult;
import edu.xaut.bookingsys.entity.CourseSession;
import edu.xaut.bookingsys.service.CourseSessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/session")
public class SessionController {
    @Autowired
    private CourseSessionService service;

    @GetMapping("/getCurSession")
    private SaResult getCurSession() {
        CourseSession curSession;
        try {
            curSession = service.getCurSession();
        } catch (Exception e) {
            return SaResult.error(e.getMessage());
        }
        return SaResult.data(curSession);
    }

}
